#pragma once
#include "os/types.h"
#include "message.h"

#define MAGIC_DUAL_BANK_UPGRADE	0x55667788
#define MAGIC_ENTER_BOOT        0x12344321
#define MAGIC_APP_READY         0xa5667667
#define MAGIC_APP_BOOT_OK       0x5aa5abcd

typedef struct {
	u32 length;
	u32 checksum;
	u32 success;
	u32 address;
} iap_info_t;

typedef struct {
	iap_info_t info;
	u32 dual_addr;
	u32 dual_len;
	u32 dual_checksum;
}dual_iap_info_t;

bool process_iap_message(message_t *message);
void iap_read_string(u8 can, const u8 *args);
void iap_send_data(u8 can, u8 *data, int len);
void iap_write_magic(u32 magic);
u32 iap_read_magic(void);

